package vos;

import java.util.Collections;
import java.util.List;

public class Page<T> {

    public static Page EMPTY = new Page();
    
    public int page;
    public int rows;
    public String order;
    public String sort;

    public int startIndex;
    public int totalCount;
    public int totalPageCount;
    public List<T> items = Collections.EMPTY_LIST;

    public static <T> Page<T> newInstance(int page, int rows,String order,String sort, int totalCount) {
        Page pagevo = new Page();
        pagevo.page = page;
        pagevo.rows = rows;
        pagevo.order=order;
        pagevo.sort=sort;
        pagevo.totalCount = totalCount;
        return pagevo;
    }
    
    public int getStartIndex(int pag,int rows) {
        if (pag > 0) {
            return rows * (pag - 1);
        }
        return 0;
    }

	public String getOrder() {
		return order;
	}

	public void setOrder(String order) {
		this.order = order;
	}

	public String getSort() {
		return sort;
	}

	public void setSort(String sort) {
		this.sort = sort;
	}


	public int getTotalCount() {
		return totalCount;
	}

	public void setTotalCount(int totalCount) {
		this.totalCount = totalCount;
	}

	public int getPage() {
		return page;
	}

	public void setPage(int page) {
		this.page = page;
	}

	public int getRows() {
		return rows;
	}

	public void setRows(int rows) {
		this.rows = rows;
	}

	public int getTotalPageCount() {
		return totalPageCount;
	}

	public void setTotalPageCount(int totalPageCount) {
		this.totalPageCount = totalPageCount;
	}

	public List<T> getItems() {
		return items;
	}

	public void setItems(List<T> items) {
		this.items = items;
	}

	public void setStartIndex(int startIndex) {
		this.startIndex = startIndex;
	}
    
}
